<template>
<div class="layerRtb layerRtb-threecolumn">
    <three-title :title="{name: '罚款记录'}"></three-title>
    <div class="layerRtb-scroll thinScroll" v-scrollHeight = "0">
        <div class="analyItem" v-for="(item,index) in fineData" :key="index">
            <p class="analyItemTit tx-center">罚款</p>
            <div class="analyItemCon">
                <div class="analyItemText clearfix">
                    <p class="col-md-4"><span class="cLightGray pr8">发起时间</span><span>{{$utils.format('yyyy-MM-dd hh:mm:ss', item.FineTime)}}</span></p>
                    <p class="col-md-4"><span class="cLightGray pr8">发起金额</span><span>{{item.FineMoney}}</span></p>
                    <p class="col-md-4"><span class="cLightGray pr8">执行时间</span><span>{{ $utils.format('yyyy-MM-dd hh:mm:ss', item.FineCLTime)}}</span></p>
                    <p class="col-md-11"><span class="cLightGray pr8">处罚原因</span><span>{{item.FineRemark}}</span></p>
                    <div class="col-md-1">
                        <a href="javascript:" class="circlemark" :class="item.FineState===3?'circlemark-green':'circlemark-lightRed'">{{item.FineState===3?'已':'未'}}</a>
                    </div>
                </div>
            </div>
        </div>
        <div class="analyItem"  v-if="fineData.length === 0 ">
            <p class="analyItemTit tx-center">罚款</p>
            <div class="analyItemCon">
                暂无奖罚记录...
            </div>
        </div>
    </div>
    <div class="layerRtb-footer">
        <div class="analyItem">
            <p class="analyItemTit tx-center">综合</p>
            <div class="analyItemCon">
                <p class="col-md-4"><span class="cLightGray pr8">发起</span>{{faqiSum}}元</p>
                <p class="col-md-4"><span class="cLightGray pr8">执行</span><span class="cGreen">{{zhiSum}}</span>元</p>
            </div>
        </div>
    </div>
</div>
</template>
<script>
import {mapGetters} from 'vuex'
import {findGcProjectFinesByOrderId} from '../../Resources/Api/paragraph'
export default {

    data () {
        return {
            fineData: [], // 奖罚记录
            zhiSum: 0 // 执行钱数
        }
    },
    mounted () {
    },
    created () {
        this.findGcProjectFinesByOrderId()
    },
    computed: {
        ...mapGetters(['leftInfo']),
        // 共钱总和
        faqiSum () {
            if (this.fineData.length > 0) {
                return this.fineData.map(item => item.FineMoney).reduce((acc, cur) => acc + cur, 0)
            } else {
                return 0
            }
        }
    },
    methods: {
        // 获取罚款记录
        findGcProjectFinesByOrderId () {
            findGcProjectFinesByOrderId({
                orderId: this.leftInfo.orderno
                // type: '12-201542',
            }).then(results => {
                if (results.data.StatusCode === 0) {
                    this.fineData = results.data.Body
                    this.fineData.forEach(item => {
                        if (item.FineState === 3) {
                            this.zhiSum += item.FineMoney
                        }
                    })
                }
            }).catch(error => {
                console.log(error)
            })
        }
    }
}
</script>
